<%
var title= isEmpty(userAccount.id)?"新增":"编辑";
layout("/common/layout.html",{"title":title+"会员"}){
%>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-8">
        <h2>${title}会员</h2>
        <ol class="breadcrumb">
            <li><a href="${ctxPath}/admin/main">主页</a></li>
            <li><a href="${ctxPath}/userAccount/view/index">会员权限管理</a></li>
            <li>会员管理</li>
            <li class="active">${title}</li>
        </ol>
    </div>
    <div class="col-sm-4">
        <div class="title-action">
            <a class="btn btn-primary btn-sm btn-outline" href="${ctxPath}/userAccount/view/index">
                <i class="fa fa-reply"> </i> 返回列表</a>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins animated fadeInDown">
        <div class="ibox-content">
            <form class="form-horizontal" id="saveForm">
                <input id="id" name="id" type="hidden" value="${userAccount.id!}">
                <div class="form-group">
                    <label class="col-sm-1 control-label-info">会员账号：</label>

                    <div class="col-sm-6">
                        <input id="userName" name="userName" class="form-control" type="text"
                               value="${userAccount.userName!}" placeholder="请输入会员昵称">
                    </div>
                </div>
                <% if(shiro.hasPermission("/userAccount/password/action")){
                if(isNotEmpty(userAccount.id)){ %>
                <div class="form-group">
                    <label class="col-sm-1 control-label-info">密码设置：</label>
                    <div class="col-sm-6">
                        <div class="input-group">
                            <input id="look_password" name="look_password" class="form-control"
                                   type="text" placeholder="初始化密码为：123456" readonly="readonly">
                            <span class="input-group-btn">
                                    <button class="btn btn-primary" id="reset_password" type="button">初始化密码</button>
                                  </span>
                        </div>
                    </div>
                </div>
                <% }
                } %>

                <div class="form-group">
                    <label class="col-sm-1 control-label-info">会员性别：</label>
                    <div class="col-sm-6">
                        <label class="radio-inline sex" for="sex1">
                            <input type="radio" value="1" name="sex" id="sex1" ${isEmpty(userAccountExtend.sex) ||
                                   userAccountExtend.sex== 1?'checked="checked"'}>
                            <i class="fa fa-venus"></i>&nbsp;男生
                        </label>
                        <label class="radio-inline" for="sex2">
                            <input type="radio" value="0" name="sex" id="sex2" ${isNotEmpty(userAccountExtend.sex) &&
                                   userAccountExtend.sex== 0?'checked="checked"'}>
                            <i class="fa fa-mars"></i>&nbsp;女生
                        </label>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-1 control-label-info">会员状态：</label>

                    <div class="col-sm-6">
                        <label class="radio-inline status" for="status1">
                            <input type="radio" value="1" name="status" id="status1" ${isEmpty(userAccount.status) ||
                                   userAccount.status== 1?'checked="checked"'}>


                            <i class="fa fa-check"></i>&nbsp;启动
                        </label>
                        <label class="radio-inline" for="status2">
                            <input type="radio" value="0" name="status" id="status2" ${isNotEmpty(userAccount.status) &&
                                   userAccount.status== 0?'checked="checked"'}>
                            <i class="fa fa-ban"></i>&nbsp;禁用
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label-info">手机号码：</label>
                    <div class="col-sm-6">
                        <input id="phone" name="phone" class="form-control" type="number" maxlength="11"
                               value="${userAccount.phone!}" placeholder="请输入手机号码">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label-info">电子邮箱：</label>
                    <div class="col-sm-6">
                        <input id="email" name="email" class="form-control" type="email" value="${userAccount.email!}"
                               placeholder="请输入电子邮箱">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label-info">角色权限：</label>
                    <div class="col-sm-6">
                        <select class="form-control roleSelect" id="roleSelect" name="roleSelect" multiple="multiple"></select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label-info">头像设置：</label>

                    <div class="col-sm-2">
                        <div class="file-box" id="uploader" style="width: auto">
                            <div class="fileImage">
                                <div id="viewImg">
                                    <% if(isNotEmpty(userAccountExtend.avatar)){ %>
                                    <img src="${uploaderFilesDomain!}${userAccountExtend.avatar!}" class="img-thumbnail"/>
                                    <% }else{ %>
                                    <div class="icon"><i class="fa fa-file-image-o"></i></div>
                                    <% } %>
                                </div>
                                <div class="fileImage-name">
                                    <input name="avatarImg" id="avatarImg" value="${uploaderFilesDomain!}${userAccountExtend.avatar!}" type="hidden"/>
                                    <div class="btn btn-primary btn-xs btn-outline center-block" id="default-avatarImg">
                                        <i class="fa fa-smile-o"></i>&nbsp;初始化默认头像
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="message-box alert alert-success">
                            <li>初始化为默认头像，无法恢复，请谨慎操作。</li>
                            <li>根据已选的性别，自动适配默认男女头像。</li>
                        </div>
                    </div>
                </div>
                <hr>
                <div class="form-group">
                    <label class="col-sm-1 control-label-info"></label>

                    <div class="col-sm-6">
                        <a href="${ctxPath}/userAccount/view/index" id="resetChange"
                           class="btn btn-lg btn-white"><i class=" fa fa-times fa-sm"></i>&nbsp;取消更改</a>
                        <a id="saveChange" class="btn btn-lg btn-primary "><i class="fa fa-check fa-sm"></i>&nbsp;保存更改</a>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>
<% } %>
<script type="text/javascript">
    //页面JS调用
    require(['user/account'], function (account) {
        account.update();
    });

</script>